﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using DataAccess.SqlClient;
using Dal;
using Model;
using ApiDAL.Common;
using System.Data;
using System.Data.SqlClient;

namespace Dal
{
    public class ReMenuDAL
    {
        #region 显示推荐套餐
        /// <summary>
        /// 显示推荐套餐
        /// </summary>
        /// <returns></returns>

        public List<ReMenu> ReMenushow()
        {
            SqlQuery sql = new SqlQuery();
            sql.CommandText = "select * from ReMenu";
            DataSet ds = SqlDataAccess.ExecDataset(sql);
            DataTable dt = ds.Tables[0];
            return DataReaderToObjectHelper.DataTableToList<ReMenu>(dt);

        }
        #endregion

        #region 添加推荐套餐
        /// <summary>
        /// 添加推荐套餐
        /// </summary>
        /// <param name="n"></param>
        /// <returns></returns>
        public int AddReMenu(int Reid, string Rename, string Rephoto, string Redescrib, int Reprice)
        {
            SqlQuery sql = new SqlQuery();
            sql.CommandText = "ReMenude";
            sql.CommandType = CommandType.StoredProcedure;
            SqlParameter cc = new SqlParameter();
            cc.Value = Reid;
            cc.ParameterName = "@Reid";
            cc.SqlDbType = System.Data.SqlDbType.VarChar;
            sql.Parameters.Add(cc);

            SqlParameter cc1 = new SqlParameter();
            cc1.Value = Rename;
            cc1.ParameterName = "@Rename";
            cc1.SqlDbType = System.Data.SqlDbType.VarChar;
            sql.Parameters.Add(cc1);

            SqlParameter cc2 = new SqlParameter();
            cc2.Value = Rephoto;
            cc2.ParameterName = "@Rephoto";
            cc2.SqlDbType = System.Data.SqlDbType.VarChar;
            sql.Parameters.Add(cc2);

            SqlParameter cc3 = new SqlParameter();
            cc3.Value = Redescrib;
            cc3.ParameterName = "@Redescrib";
            cc3.SqlDbType = System.Data.SqlDbType.VarChar;
            sql.Parameters.Add(cc3);

            SqlParameter cc4 = new SqlParameter();
            cc4.Value = Reprice;
            cc4.ParameterName = "@Reprice";
            cc4.SqlDbType = System.Data.SqlDbType.VarChar;
            sql.Parameters.Add(cc4);

            int i = Convert.ToInt32(SqlDataAccess.ExecNonQuery(sql));
            return i;
        }
        #endregion

        #region 删除今日推荐
        /// <summary>
        /// 删除今日推荐
        /// </summary>
        /// <param name="id"></param>
        /// <returns></returns>
        public int delReMenu()
        {
            SqlQuery sql = new SqlQuery();
            sql.CommandText = "delete from ReMenu where 1=1";
            return SqlDataAccess.ExecNonQuery(sql);

        }
        #endregion

    }
}
